// 第一种get
function ajax(url, fnOnSucc, fnOnFaild) {
	var xhr = null;

	//1.初始化Ajax对象
	if (window.ActiveXObject) {
		xhr = new ActiveXObject("Msxml2.XMLHTTP") || new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		xhr = new XMLHttpRequest();
	}

	//2.建立连接
	xhr.open('get', url, true);

	//3.监控请求状态
	xhr.onreadystatechange = function() {
		//readyState->Ajax对象内部的状态
		//status->服务器返回的请求结果
		if (xhr.readyState == 4) {
			//alert('请求完成，请求结果是：'+xhr.status);
			//alert(xhr.responseText);
			if (xhr.status == 200) {
				if (fnOnSucc) {
					fnOnSucc(xhr.responseText);
				}
			} else {
				if (fnOnFaild) {
					fnOnFaild(xhr.status);
				}
			}
		}
		//alert(xhr.readyState);
		//alert(typeof xhr.status);
	};

	//4.发送请求
	xhr.send();

	//5.*清理
	//xhr.onreadystatechange=null;
	//xhr=null;
}


// 第二种post
function ajaxPost(url, sData, fnOnSucc, fnOnFaild) {
	var xhr = null;

	//1.初始化Ajax对象
	if (window.ActiveXObject) {
		xhr = new ActiveXObject("Msxml2.XMLHTTP") || new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		xhr = new XMLHttpRequest();
	}

	//2.建立连接
	xhr.open('post', url, true);

	//3.监控请求状态
	xhr.onreadystatechange = function() {
		//readyState->Ajax对象内部的状态
		//status->服务器返回的请求结果
		if (xhr.readyState == 4) {
			//alert('请求完成，请求结果是：'+xhr.status);
			//alert(xhr.responseText);
			if (xhr.status == 200) {
				if (fnOnSucc) {
					fnOnSucc(xhr.responseText);
				}
			} else {
				if (fnOnFaild) {
					fnOnFaild(xhr.status);
				}
			}
		}
		//alert(xhr.readyState);
		//alert(typeof xhr.status);
	};

	//4.发送请求
	xhr.setRequestHeader('content-type', 'urlencode');
	xhr.send(sData);

}